package com.meals.system.service.impl;

import com.meals.system.api.user.vo.WhitesMealOrderDetailVO;
import com.meals.system.api.user.vo.WhitesMealOrderItemVO;
import com.meals.system.api.user.vo.WhitesMealOrderListVO;
import com.meals.system.api.user.vo.WhitesMealShoppingCartItemVO;
import com.meals.system.common.*;
import com.meals.system.dao.*;
import com.meals.system.entity.*;
import com.meals.system.service.WhitesMealOrderService;
import com.meals.system.util.BeanUtil;
import com.meals.system.util.NumberUtil;
import com.meals.system.util.PageQueryUtil;
import com.meals.system.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.groupingBy;

/**
 * Description:
 * Parm:
 * return:
 * Author: Chen
 * Date: 2021/12/11
 */
@Service
public class WhitesMealOrderServiceImpl implements WhitesMealOrderService {

    @Autowired
    private WhitesMealGoodsMapper whitesMealGoodsMapper;
    @Autowired
    private WhitesMealOrderMapper whitesMealOrderMapper;
    @Autowired
    private WhitesMealOrderItemMapper whitesMealOrderItemMapper;
    @Autowired
    private WhitesMealOrderAddressMapper whitesMealOrderAddressMapper;
    @Autowired
    private WhitesMealShoppingCartItemMapper whitesMealShoppingCartItemMapper;



    // WhitesMealOrderDetailVO多层架构 包含订单物品列表
    //  @ApiModelProperty("订单项列表")
    //  private List<WhitesMealOrderItemVO> whitesMealOrderItemVOS;
    @Override
    public WhitesMealOrderDetailVO getOrderDetailByOrderId(Long orderId) {
        WhitesMealOrder whitesMealOrder = whitesMealOrderMapper.selectByPrimaryKey(orderId);
        if (whitesMealOrder == null){
            SystemException.fail(ServiceResultEnum.DATA_NOT_EXIST.getResult());
            return null;
        }
        // 根据orderId获取orderItem列表
        List<WhitesMealOrderItem> orderItems = whitesMealOrderItemMapper.selectByOrderId(whitesMealOrder.getOrderId());
        if (CollectionUtils.isEmpty(orderItems)){
            SystemException.fail(ServiceResultEnum.ORDER_ITEM_NULL_ERROR.getResult());
            return null;
        }
        // 把whitesMealOrder 和 orderItems 转为VO类型给页面用
        List<WhitesMealOrderItemVO> whitesMealOrderItemVOS = BeanUtil.copyList(orderItems, WhitesMealOrderItemVO.class);
        WhitesMealOrderDetailVO whitesMealOrderDetailVO = new WhitesMealOrderDetailVO();
        BeanUtil.copyProperties(whitesMealOrder, whitesMealOrderDetailVO);
        // entity 没有的三个属性
        // 支付状态
        whitesMealOrderDetailVO.setOrderStatusString(WhitesMealOrderStatusEnum.getWhitesMealOrderStatusEnumByStatus(whitesMealOrderDetailVO.getOrderStatus()).getName());
        // 支付方式
        whitesMealOrderDetailVO.setPayTypeString(PayTypeEnum.getPayTypeEnumByType(whitesMealOrderDetailVO.getPayType()).getName());
        // 物品信息列表
        whitesMealOrderDetailVO.setWhitesMealOrderItemVOS(whitesMealOrderItemVOS);
        return whitesMealOrderDetailVO;
    }

    @Override
    public WhitesMealOrderDetailVO getOrderDetailByOrderNoWithUserId(String orderNo, Long userId) {
        WhitesMealOrder whitesMealOrder = whitesMealOrderMapper.selectByOrderNo(orderNo);
        if (whitesMealOrder == null){
            SystemException.fail(ServiceResultEnum.DATA_NOT_EXIST.getResult());
            return null;
        }
        // userId和order对应的userId不同
        if (!userId.equals(whitesMealOrder.getUserId())){
            SystemException.fail(ServiceResultEnum.REQUEST_FORBIDEN_ERROR.getResult());
            return null;
        }
        List<WhitesMealOrderItem> orderItems = whitesMealOrderItemMapper.selectByOrderId(whitesMealOrder.getOrderId());
        if (CollectionUtils.isEmpty(orderItems)){
            SystemException.fail(ServiceResultEnum.ORDER_ITEM_NULL_ERROR.getResult());
            return null;
        }
        // 把whitesMealOrder 和 orderItems 转为VO类型给页面用
        List<WhitesMealOrderItemVO> whitesMealOrderItemVOS = BeanUtil.copyList(orderItems, WhitesMealOrderItemVO.class);
        WhitesMealOrderDetailVO whitesMealOrderDetailVO = new WhitesMealOrderDetailVO();
        BeanUtil.copyProperties(whitesMealOrder, whitesMealOrderDetailVO);
        // entity 没有的三个属性
        // 订单状态
        whitesMealOrderDetailVO.setOrderStatusString(WhitesMealOrderStatusEnum.getWhitesMealOrderStatusEnumByStatus(whitesMealOrderDetailVO.getOrderStatus()).getName());
        // 支付方式
        whitesMealOrderDetailVO.setPayTypeString(PayTypeEnum.getPayTypeEnumByType(whitesMealOrderDetailVO.getPayType()).getName());
        // 物品信息列表
        whitesMealOrderDetailVO.setWhitesMealOrderItemVOS(whitesMealOrderItemVOS);
        return whitesMealOrderDetailVO;
    }

    @Override
    public PageResult getOrders(PageQueryUtil pageUtil) {
        int total =whitesMealOrderMapper.getTotalWhitesMealOrders(pageUtil);
        List<WhitesMealOrder> whitesMealOrders = whitesMealOrderMapper.findWhitesMealOrderList(pageUtil);
        List<WhitesMealOrderListVO> whitesMealOrderListVOS = new ArrayList<>();
        if (total > 0){
            // 数据转换，将实体类转成vo
            whitesMealOrderListVOS = BeanUtil.copyList(whitesMealOrders, WhitesMealOrderListVO.class);
            // 设置订单状态
            for (WhitesMealOrderListVO whitesMealOrderListVO : whitesMealOrderListVOS){
                whitesMealOrderListVO.setOrderStatusString(WhitesMealOrderStatusEnum.getWhitesMealOrderStatusEnumByStatus(whitesMealOrderListVO.getOrderStatus()).getName());
            }
            // 设置订单项列表 WhitesMealOrderItemVOS
            // 获取orderIds
            List<Long> orderIds = whitesMealOrders.stream().map(WhitesMealOrder::getOrderId).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(orderIds)){
                List<WhitesMealOrderItem> orderItems = whitesMealOrderItemMapper.selectByOrderIds(orderIds);
                // key: orderId value: List<WhitesMealOrderItem>
                Map<Long, List<WhitesMealOrderItem>> itemByOrderIdMap = orderItems.stream().collect(groupingBy(WhitesMealOrderItem::getOrderId));


                // whitesMealOrderListVOS whitesMealOrders 转为 WhitesMealOrderListVO 的一个列表
                // itemByOrderIdMap orderItems转成的map key: orderId value: List<WhitesMealOrderItem>
                for (WhitesMealOrderListVO whitesMealOrderListVO : whitesMealOrderListVOS){
                    // 封装每个订单列表对象的订单数据
                    if (itemByOrderIdMap.containsKey(whitesMealOrderListVO.getOrderId())){
                        List<WhitesMealOrderItem> orderItemList = itemByOrderIdMap.get(whitesMealOrderListVO.getOrderId());
                        // Item 转化为 ItemVo
                        List<WhitesMealOrderItemVO> whitesMealOrderItemVOS = BeanUtil.copyList(orderItemList, WhitesMealOrderItemVO.class);
                        whitesMealOrderListVO.setWhitesMealOrderItemVOS(whitesMealOrderItemVOS);
                    }
                }
            }
        }
        PageResult pageResult = new PageResult(whitesMealOrderListVOS, total, pageUtil.getLimit(), pageUtil.getPage());
        return pageResult;

    }

    @Override
    public String cancelOrder(String orderNo, Long userId) {
        WhitesMealOrder whitesMealOrder = whitesMealOrderMapper.selectByOrderNo(orderNo);
        if (whitesMealOrder != null){
            // 验证是不是当前的userId下的订单
            if (!userId.equals(whitesMealOrder.getUserId())){
                SystemException.fail(ServiceResultEnum.NO_PERMISSION_ERROR.getResult());
            }
            // 订单状态判断
            if (whitesMealOrder.getOrderStatus() == WhitesMealOrderStatusEnum.ORDER_SUCCESS.getOrderStatus()
                    ||whitesMealOrder.getOrderStatus() == WhitesMealOrderStatusEnum.ORDER_CLOSED_BY_SYSTEM_USER.getOrderStatus()
                    ||whitesMealOrder.getOrderStatus() == WhitesMealOrderStatusEnum.ORDER_CLOSED_BY_EXPIRED.getOrderStatus()
                    ||whitesMealOrder.getOrderStatus() == WhitesMealOrderStatusEnum.ORDER_CLOSED_BY_SYSTEM_SELLER.getOrderStatus()
                    ||whitesMealOrder.getOrderStatus() == WhitesMealOrderStatusEnum.ORDER_CLOSED_BY_ADMIN.getOrderStatus()){
                return ServiceResultEnum.ORDER_STATUS_ERROR.getResult();
            }
            if (whitesMealOrderMapper.closeOrder(Collections.singletonList(whitesMealOrder.getOrderId()),WhitesMealOrderStatusEnum.ORDER_CLOSED_BY_SYSTEM_USER.getOrderStatus()) > 0 ){
                return ServiceResultEnum.SUCCESS.getResult();
            } else {
                return ServiceResultEnum.DB_ERROR.getResult();
            }
        }
        return ServiceResultEnum.ORDER_NOT_EXIST_ERROR.getResult();
    }


    @Override
    public String confirmOrder(String orderNo, Long userId) {
        WhitesMealOrder whitesMealOrder = whitesMealOrderMapper.selectByOrderNo(orderNo);
        if (whitesMealOrder != null){
            // 验证是不是当前的userId下的订单
            if (!userId.equals(whitesMealOrder.getUserId())){
                SystemException.fail(ServiceResultEnum.NO_PERMISSION_ERROR.getResult());
            }
            // 检查订单状态 是否为出库状态，非出库状态报错
            if (whitesMealOrder.getOrderStatus().intValue() != WhitesMealOrderStatusEnum.ORDER_EXPRESS.getOrderStatus()){
                return ServiceResultEnum.ORDER_STATUS_ERROR.getResult();
            }
            // 出库状态，则设置好数据
            whitesMealOrder.setOrderStatus((byte) WhitesMealOrderStatusEnum.ORDER_SUCCESS.getOrderStatus());
            whitesMealOrder.setUpdateTime(new Date());
            if (whitesMealOrderMapper.updateByPrimaryKey(whitesMealOrder) > 0){
                return ServiceResultEnum.SUCCESS.getResult();
            } else {
                return ServiceResultEnum.DB_ERROR.getResult();
            }
        }
        return ServiceResultEnum.ORDER_NOT_EXIST_ERROR.getResult();
    }

    @Override
    public String paySuccess(String orderNo, int payType) {
        WhitesMealOrder whitesMealOrder = whitesMealOrderMapper.selectByOrderNo(orderNo);
        if (whitesMealOrder != null){
            // 验证现在是不是待支付状态，非支付状态报错
            if (whitesMealOrder.getOrderStatus().intValue() != WhitesMealOrderStatusEnum.ORDER_PRE_PAY.getOrderStatus()){
                return ServiceResultEnum.ORDER_STATUS_ERROR.getResult();
            }
            whitesMealOrder.setOrderStatus((byte) WhitesMealOrderStatusEnum.ORDER_PAID.getOrderStatus());
            whitesMealOrder.setPayType((byte) payType);
            whitesMealOrder.setPayStatus((byte) PayStatusEnum.PAY_SUCCESS.getPayStatus());
            whitesMealOrder.setPayTime(new Date());
            whitesMealOrder.setUpdateTime(new Date());
            if (whitesMealOrderMapper.updateByPrimaryKeySelective(whitesMealOrder) > 0){
                return ServiceResultEnum.SUCCESS.getResult();
            } else {
                return ServiceResultEnum.DB_ERROR.getResult();
            }
        }
        return ServiceResultEnum.ORDER_NOT_EXIST_ERROR.getResult();
    }


    // 生成订单 多步骤多种情况判断
    @Override
    @Transactional
    public String saveOrder(SystemUser loginSystemUser, SystemUserAddress systemUserAddress, List<WhitesMealShoppingCartItemVO> items) {
        // 默认一个订单只能有一个seller
        Long sellerId = null;
        List<Long> itemIdList = items.stream().map(WhitesMealShoppingCartItemVO::getCartItemId).collect(Collectors.toList());
        List<Long> goodsIds = items.stream().map(WhitesMealShoppingCartItemVO::getGoodsId).collect(Collectors.toList());
        List<WhitesMealGoods> whitesMealGoods = whitesMealGoodsMapper.selectByPrimaryKeys(goodsIds);

        // 1、检查是否包含已下架商品
        List<WhitesMealGoods> goodsListNoSell = whitesMealGoods.stream().filter(whitesMealGoodsTemp -> whitesMealGoodsTemp.getGoodsSellStatus() != Constants.SELL_STATUS_UP).collect(Collectors.toList());
        if (!CollectionUtils.isEmpty(goodsListNoSell)){
            // goodsListNoSell为非空，有下架的商品
            SystemException.fail(goodsListNoSell.get(0).getGoodsName() + "商品已下架，无法生成订单");
        }
        Map<Long, WhitesMealGoods> whitesMealGoodsMap = whitesMealGoods.stream().collect(Collectors.toMap(WhitesMealGoods::getGoodsId, Function.identity(), (entity1, entity2) -> entity1));

        // 2、判断商品库存
        for (WhitesMealShoppingCartItemVO shoppingCartItemVO : items){
            // 查出的商品不存在购物车中的这条关联商品数据，直接返回错误提醒
            if (! whitesMealGoodsMap.containsKey(shoppingCartItemVO.getGoodsId())){
                SystemException.fail(ServiceResultEnum.SHOPPING_ITEM_ERROR.getResult());
            }
            // 存在数量大于库存的情况，直接返回错误提醒
            if (shoppingCartItemVO.getGoodsCount() > whitesMealGoodsMap.get(shoppingCartItemVO.getGoodsId()).getStockNum()){
                SystemException.fail(ServiceResultEnum.SHOPPING_ITEM_COUNT_ERROR.getResult());
            }
            sellerId = shoppingCartItemVO.getSellerId();
        }

        // 3、删除购物项
        if (!CollectionUtils.isEmpty(itemIdList) && !CollectionUtils.isEmpty(goodsIds) && !CollectionUtils.isEmpty(whitesMealGoods)){
            if (whitesMealShoppingCartItemMapper.deleteBatch(itemIdList) > 0){
                List<StockNumDTO> stockNumDTOS = BeanUtil.copyList(items, StockNumDTO.class);
                int updateStockNum = whitesMealGoodsMapper.updateStockNum(stockNumDTOS);
                if (updateStockNum < 1){
                    SystemException.fail(ServiceResultEnum.SHOPPING_ITEM_COUNT_ERROR.getResult());
                }
                // 生成订单号
                String orderNo = NumberUtil.genOrderNo();
                int priceTotal = 0;
                // 保存订单
                WhitesMealOrder whitesMealOrder = new WhitesMealOrder();
                whitesMealOrder.setOrderNo(orderNo);

                // 设置whitesMealOrder的seller_id
                whitesMealOrder.setSellerId(sellerId);
                whitesMealOrder.setUserId(loginSystemUser.getUserId());
                // 总价
                for (WhitesMealShoppingCartItemVO whitesMealShoppingCartItemVO : items){
                    priceTotal += whitesMealShoppingCartItemVO.getGoodsCount() * whitesMealShoppingCartItemVO.getSellingPrice();
                }
                if (priceTotal <= 0){
                    SystemException.fail(ServiceResultEnum.ORDER_PRICE_ERROR.getResult());
                }
                whitesMealOrder.setTotalPrice(priceTotal);
                String extraInfo = "";
                whitesMealOrder.setExtraInfo(extraInfo);
                // 生成订单项保存订单项记录
                if (whitesMealOrderMapper.insertSelective(whitesMealOrder) > 0){
                    // 生成订单收货地址
                    WhitesMealOrderAddress whitesMealOrderAddress = new WhitesMealOrderAddress();
                    BeanUtil.copyProperties(systemUserAddress, whitesMealOrderAddress);
                    whitesMealOrderAddress.setOrderId(whitesMealOrder.getOrderId());
                    // 生成所有的订单快照，保存到数据库
                    List<WhitesMealOrderItem> whitesMealOrderItems = new ArrayList<>();
                    for (WhitesMealShoppingCartItemVO whitesMealShoppingCartItemVO : items){
                        WhitesMealOrderItem whitesMealOrderItem = new WhitesMealOrderItem();
                        // 使用BeanUtil辅助工具类将whitesMealShoppingCartItemVO中的属性复制到
                        BeanUtil.copyProperties(whitesMealShoppingCartItemVO, whitesMealOrderItem);
                        // WhitesMealOrderMapper.xml文件insert()方法中使用了useGeneratedKey因此orderId可以获取到
                        whitesMealOrderItem.setOrderId(whitesMealOrder.getOrderId());
                        whitesMealOrderItems.add(whitesMealOrderItem);
                    }
                    // 保存至数据库
                    if (whitesMealOrderItemMapper.insertBatch(whitesMealOrderItems) > 0 && whitesMealOrderAddressMapper.insertSelective(whitesMealOrderAddress) > 0){
                        //所有操作成功后，将订单号返回，以供Controller方法跳转到订单详情
                        return orderNo;
                    }
                    SystemException.fail(ServiceResultEnum.ORDER_PRICE_ERROR.getResult());
                }
                SystemException.fail(ServiceResultEnum.DB_ERROR.getResult());
            }
            SystemException.fail(ServiceResultEnum.DB_ERROR.getResult());
        }
        SystemException.fail(ServiceResultEnum.SHOPPING_ITEM_ERROR.getResult());
        return ServiceResultEnum.SHOPPING_ITEM_ERROR.getResult();
    }

    @Override
    public PageResult getWhitesMealOrdersPage(PageQueryUtil pageUtil) {
        List<WhitesMealOrder> whitesMealOrders = whitesMealOrderMapper.findWhitesMealOrderList(pageUtil);
        int total = whitesMealOrderMapper.getTotalWhitesMealOrders(pageUtil);
        PageResult pageResult = new PageResult(whitesMealOrders,total,pageUtil.getLimit(),pageUtil.getPage());
        return pageResult;
    }

    @Override
    @Transactional
    public String updateOrderInfo(WhitesMealOrder whitesMealOrder) {
        WhitesMealOrder temp = whitesMealOrderMapper.selectByPrimaryKey(whitesMealOrder.getOrderId());
        // 两个条件 1.不为空 2. 3>orderStatus>=0 出库前且状态正常则可以修改
        if (temp != null && temp.getOrderStatus() < 3 && temp.getOrderStatus() >= 0){
            temp.setTotalPrice(whitesMealOrder.getTotalPrice());
            temp.setUpdateTime(new Date());
            if (whitesMealOrderMapper.updateByPrimaryKeySelective(temp) > 0){
                return ServiceResultEnum.SUCCESS.getResult();
            }
            return ServiceResultEnum.DB_ERROR.getResult();
        }
        return ServiceResultEnum.ORDER_NOT_EXIST_ERROR.getResult();

    }

    @Override
    @Transactional
    // 将订单状态改为配货完成
    public String checkDone(Long[] ids) {
        // 查询所有的订单 判断状态 修改状态和更新时间
        List<WhitesMealOrder> orders = whitesMealOrderMapper.selectByPrimaryKeys(Arrays.asList(ids));
        String errorOrderNos = "";
        if (!CollectionUtils.isEmpty(orders)){
            for (WhitesMealOrder whitesMealOrder : orders){
                if (whitesMealOrder.getIsDeleted() == 1){
                    errorOrderNos += whitesMealOrder.getOrderNo() + " ";
                    continue;
                }
                // 订单状态不是1，即订单状态不是已支付
                if (whitesMealOrder.getOrderStatus() != 1){
                    errorOrderNos += whitesMealOrder.getOrderNo() + " ";
                }
            }
            if (StringUtils.isEmpty(errorOrderNos)){
                // 订单状态正常及已经支付了 可以执行配货操作 修改订单状态和更新时间
                if (whitesMealOrderMapper.checkDone(Arrays.asList(ids)) > 0){
                    return ServiceResultEnum.SUCCESS.getResult();
                } else {
                    return ServiceResultEnum.DB_ERROR.getResult();
                }
            } else {
                return errorOrderNos + "订单的状态不是已支付无法将进行配货完成操作";
            }
        }
        // 未查到数据
        return ServiceResultEnum.DATA_NOT_EXIST.getResult();
    }

    @Override
    @Transactional
    // 将订单状态改为出库成功
    public String checkOut(Long[] ids) {
        // 查询所有的订单 判断状态 修改状态和更新时间
        List<WhitesMealOrder> orders = whitesMealOrderMapper.selectByPrimaryKeys(Arrays.asList(ids));
        String errorOrderNos = "";
        if (!CollectionUtils.isEmpty(orders)){
            for (WhitesMealOrder whitesMealOrder : orders){
                if (whitesMealOrder.getIsDeleted() == 1){
                    errorOrderNos += whitesMealOrder.getOrderNo() + " ";
                    continue;
                }
                // 订单状态不是1或2，即订单状态不是已支付 或 已配货
                if (whitesMealOrder.getOrderStatus() != 1 && whitesMealOrder.getOrderStatus() != 2){
                    errorOrderNos += whitesMealOrder.getOrderNo() + " ";
                }
            }
            if (StringUtils.isEmpty(errorOrderNos)){
                // 订单状态正常 可以执行出库操作 修改订单状态和更新时间
                if (whitesMealOrderMapper.checkOut(Arrays.asList(ids)) > 0){
                    return ServiceResultEnum.SUCCESS.getResult();
                } else {
                    return ServiceResultEnum.DB_ERROR.getResult();
                }
            } else {
                return errorOrderNos + "订单的状态不是支付成功或配货完成无法进行出库操作";
            }
        }
        // 未查到数据
        return ServiceResultEnum.DATA_NOT_EXIST.getResult();
    }

    @Override
    @Transactional
    // 将订单状态改为商家关闭
    public String closeOrder(Long[] ids) {
        // 查询所有的订单 判断状态 修改状态和更新时间
        List<WhitesMealOrder> orders = whitesMealOrderMapper.selectByPrimaryKeys(Arrays.asList(ids));
        String errorOrderNos = "";
        if (!CollectionUtils.isEmpty(orders)){
            for (WhitesMealOrder whitesMealOrder : orders){
                if (whitesMealOrder.getIsDeleted() == 1){
                    errorOrderNos += whitesMealOrder.getOrderNo() + " ";
                    continue;
                }
                //  4: 交易成功 <0: 已经关闭
                if (whitesMealOrder.getOrderStatus() == 4 || whitesMealOrder.getOrderStatus() < 0){
                    errorOrderNos += whitesMealOrder.getOrderNo() + " ";
                }
            }
            if (StringUtils.isEmpty(errorOrderNos)){
                // 订单状态正常 可以执行关闭操作 修改订单状态和更新时间
                if (whitesMealOrderMapper.closeOrder(Arrays.asList(ids),WhitesMealOrderStatusEnum.ORDER_CLOSED_BY_SYSTEM_SELLER.getOrderStatus())>0){
                    return ServiceResultEnum.SUCCESS.getResult();
                } else {
                    return ServiceResultEnum.DB_ERROR.getResult();
                }
            } else{
                return errorOrderNos + "订单已经交易成功或已经被关闭，订单不能执行关闭操作";
            }
        }
        // 未查到数据
        return ServiceResultEnum.DATA_NOT_EXIST.getResult();
    }

    @Override
    public List<WhitesMealOrderItemVO> getOrderItems(Long orderId) {
        WhitesMealOrder whitesMealOrder = whitesMealOrderMapper.selectByPrimaryKey(orderId);
        if (whitesMealOrder != null){
            List<WhitesMealOrderItem> orderItems = whitesMealOrderItemMapper.selectByOrderId(whitesMealOrder.getOrderId());
            // 获取订单想数据
            if (!CollectionUtils.isEmpty(orderItems)){
                List<WhitesMealOrderItemVO> whitesMealOrderItemVOS = BeanUtil.copyList(orderItems, WhitesMealOrderItemVO.class);
                return whitesMealOrderItemVOS;
            }
        }
        return null;
    }

}
